<?php
namespace Home\Model;
class CommonBiz {

	public static function getUUid(){
		static $guid = '';
		$uid = uniqid("", true);
		$data = $namespace;
		$data .= $_SERVER['REQUEST_TIME'];
		$data .= $_SERVER['HTTP_USER_AGENT'];
		$data .= $_SERVER['LOCAL_ADDR'];
		$data .= $_SERVER['LOCAL_PORT'];
		$data .= $_SERVER['REMOTE_ADDR'];
		$data .= $_SERVER['REMOTE_PORT'];
		$hash = strtoupper(hash('ripemd128', $uid . $guid . md5($data)));
		$guid =
		substr($hash,  0,  8) .
		'-' .
		substr($hash,  8,  4) .
		'-' .
		substr($hash, 12,  4) .
		'-' .
		substr($hash, 16,  4) .
		'-' .
		substr($hash, 20, 12) ;
		return $guid;
	}


	public static function getGetParamsStr(){
		$get_str_array = array();
		$all_get_keys = array_keys($_GET);
	
		foreach($all_get_keys as $key){
			if(!is_numeric($key)){
				array_push($get_str_array, $key."=".$_GET[$key]);
			}
		}
		$get_str = implode('&', $get_str_array);
		return $get_str;
	}

	
	public static function getPostParamsStr(){
		$get_str_array = array();
		$all_get_keys = array_keys(I('post.'));
		foreach($all_get_keys as $key){
			if(!is_numeric($key)){
				array_push($get_str_array, $key."=".$_POST[$key]);
			}
		}
		$get_str = implode('&', $get_str_array);
		return $get_str;
	}
	
	
	public static function getParamsStr(){
		$str_array 	= array();
		$get_str 	= CommonBiz::getGetParamsStr();
		$post_str 	= CommonBiz::getPostParamsStr();
		array_push($str_array, $get_str);
		array_push($str_array, $post_str);
	
		$str 		= implode('&', $str_array);
		return trim($str, '&');
	}


	public static function saveOperation($userId,$type,$domain,$moudle,$util,$paramsText)
	{
		//写入order_payment
		$user_operation_log_en = array(
				'user_id'		=> $userId,
				'type'	=> $type,
				'domain'=> $domain,
				'moudle'=> $moudle,
				'util'		=> $util,
				'param_text'=>$paramsText,
				'create_user'	=> 'UserOperationBiz',
				'create_date'	=> date("y-m-d H:i:s", time()),
		);
		M('user_operation_log','','DB_system')->add($user_operation_log_en);
	}
	

    public static function getPageServerConfig(){
        $server_config_array = array();
        $server_config_array['ThemeConfig'] = C('ThemeConfig');
        return $server_config_array;
    }
}